package thread.knn.bean;
/*
    用于比较两个distance之间的大小
 */
public class Distance implements Comparable<Distance>{
    // 距离对应的索引
    private int index;
    // index索引的距离
    private double distance;

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public double getDistance() {
        return distance;
    }

    public void setDistance(double distance) {
        this.distance = distance;
    }

    /**
     * 比较两个distance之间的大小
     * @param o the object to be compared.
     * @return
     */
    @Override
    public int compareTo(Distance o) {
        if (this.distance == o.distance) return 0;
        return this.distance > o.distance? 1 : -1;
    }
}
